package com.powernobug.util;


public class PageUtil {
    // 计算偏移量
    public static int offset(Integer page, Integer limit) {
        return (page - 1) * limit;
    }

    // 计算页码
    public static int pages(Integer limit, long total) {
        // 三目表达式
        //return (int) (total % limit == 0 ? total / limit : total / limit + 1);

        if (total % limit == 0) {
            return (int) (total / limit);
        } else {
            return (int) (total / limit + 1);
        }
    }
}
